package com.example.weatherforecast.weatherdatatool;

import com.example.weatherforecast.R;

import java.util.HashMap;
import java.util.Map;

public class RecentWeatherInfo {
    private String date;
    private String week;
    private  String type;
    private String temperature;
    private static final Map<String, Integer> weatherTypeImageMap = new HashMap<>();

    public RecentWeatherInfo(String date, String week, String type, String temperature) {
        this.date = date;
        this.week = week;
        this.type = type;
        this.temperature = temperature;
    }

   static  {
        // 将天气类型和对应的图片资源放入映射中
        weatherTypeImageMap.put("晴", R.mipmap.sunny);
        weatherTypeImageMap.put("多云", R.mipmap.cloudy);
        weatherTypeImageMap.put("阴", R.mipmap.yin);
        weatherTypeImageMap.put("霾", R.mipmap.smog);
        weatherTypeImageMap.put("小雨", R.mipmap.rain);
        weatherTypeImageMap.put("中雨", R.mipmap.zhong_rain);
        weatherTypeImageMap.put("大雨", R.mipmap.da_rain);
        weatherTypeImageMap.put("雷阵雨", R.mipmap.thunderstorm);
        weatherTypeImageMap.put("雾", R.mipmap.fog);
        weatherTypeImageMap.put("小雪", R.mipmap.xiao_snow);
        weatherTypeImageMap.put("中雪", R.mipmap.zhong_snow);
        weatherTypeImageMap.put("大雪", R.mipmap.da_snow);
        weatherTypeImageMap.put("雨夹雪", R.mipmap.rain_snow);

    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public String getWeek() {
        return week;
    }

    public void setWeek(String week) {
        this.week = week;
    }

    public String getWeatherType() {
        return type;
    }

    public void setWeatherType(String weatherType) {
        this.type = type;
    }

    public String getTemperature() {
        return temperature;
    }

    public void setTemperature(String temperature) {
        this.temperature = temperature;
    }

    public  int getWeatherTypeImageResource() {
        // 根据天气类型获取对应的图片资源，如果未找到对应的图片资源，默认返回一个默认图片资源
        return weatherTypeImageMap.getOrDefault(type, R.mipmap.fail);
    }
}
